package com.darker.secking.config;




import org.springframework.amqp.core.*;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


//MQ队列
@Configuration
public class RabbitMQConfig {
    private static final String  QUEUE="seckillQueue";
    private static final String  EXCHANGE="seckillExchange";
//    秒杀订单队列
    @Bean
    public Queue seckillQueue(){
        return new Queue(QUEUE);
    }
//  秒杀订单路由
    @Bean
    public TopicExchange topicExchange(){
        return new TopicExchange(EXCHANGE);
    }
    @Bean
    public Binding seckillQueueBindExchange(){
        return BindingBuilder.bind(seckillQueue())
                .to(topicExchange())
                .with("seckill.#");
    }
    //配置消息转换器 序列化
    @Bean
    public MessageConverter jsonMessageConverter(){
        return new Jackson2JsonMessageConverter();
    }


}
